<?php
class AppController extends Controller {
	var $components = array ('Session','email');
	var $uses = array('User','SiteSetting');
	var $settings;
    
	function beforeFilter()
	{
	   $this->settings = $this->SiteSetting->getAll();	
       //debug($this->settings);
	}
	
    function checkPermission($permission)
    {
        return (in_array($permission,$this->Session->read('User.permissions')))?true:false;
    }
    
    function check($permission,$message='',$redirect='/')
    {
        if($this->checkPermission($permission))
        {
            return ;
        }
        if($message=='') $message = __('Access Denied',true);
        $this->Session->setFlash($message,true);
        $this->redirect($redirect);
    }
}
?>
